package com.yoshino.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * University 就是 Composite,可以管理 College
 * @author yoshino
 **/
public class University extends OrganizationComponent{

    List<OrganizationComponent> organizationComponents = new ArrayList<>();

    public University(String name, String des) {
        super(name, des);
    }

    // 重写add


    @Override
    protected void add(OrganizationComponent organizationComponent) {
        organizationComponents.add(organizationComponent);
    }

    @Override
    protected void remove(OrganizationComponent organizationComponent) {
        organizationComponents.remove(organizationComponent);
    }

    @Override
    protected void print() {
        System.out.println("--------------" + getName() + "------------------");
        for (OrganizationComponent oc : organizationComponents) {
            oc.print();
        }
    }
}
